package eu.dicode.analysis.demonstrator;


import eu.dicode.analysis.demonstrator.model.HomeCommand;
import eu.dicode.analysis.demonstrator.util.CommandPopulator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;

/**
 * Handles requests for the application home page.
 */
@Controller
public class HomeController {

	private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
  private final CommandPopulator pop;

  public HomeController() throws IOException {
    this.pop = new CommandPopulator();
  }
	/**
	 * Simply selects the home view to render by returning its name.
	 */
	@RequestMapping(value="/home", method=RequestMethod.GET)
	public String home(final Model model) {
	  final HomeCommand homeCommand = new HomeCommand();
    this.pop.populate(homeCommand);
    model.addAttribute("homeCommand", homeCommand);
		return "home";
	}
}

